Avoid endless loop of mod_rewrite
Avoid endless loop of mod_rewrite
am 08.03.2010 06:17:19 von Michael Menegakis
Hi all
A rule is in place that that rewrites domains to www.domains
In one particular home dir, I need the opposite,
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
But it goes into an endless loop that eventually makes firefox spit
'The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for
this address in a way that will never complete.'
How to ignore the higher level rule?
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Avoid endless loop of mod_rewrite
am 08.03.2010 06:51:51 von Igor Cicimov
--0016367b6d5e5cbb6f048143a924
Content-Type: text/plain; charset=ISO-8859-1
Try using the following to stop the endless loops:
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
Igor
On Mon, Mar 8, 2010 at 4:17 PM, Michael Menegakis wrote:
> Hi all
>
> A rule is in place that that rewrites domains to www.domains
>
> In one particular home dir, I need the opposite,
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
> RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
>
> But it goes into an endless loop that eventually makes firefox spit
>
> 'The page isn't redirecting properly
> Firefox has detected that the server is redirecting the request for
> this address in a way that will never complete.'
>
> How to ignore the higher level rule?
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
--0016367b6d5e5cbb6f048143a924
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Try using the following to stop the endless loops:
RewriteCond %{ENV=
:REDIRECT_STATUS} 200
RewriteRule .* - [L]
Igor
=3D"gmail_quote">On Mon, Mar 8, 2010 at 4:17 PM, Michael Menegakis
r=3D"ltr"><><=
/span> wrote:
r-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi all
A rule is in place that that rewrites domains to www.domains
In one particular home dir, I need the opposite,
RewriteEngine On
RewriteCond %{HTTP_HOST} ^
k">www.domain.com$ [NC]
RewriteRule ^(.*)$ http:=
//domain.com/$1 [R=3D301,L]
But it goes into an endless loop that eventually makes firefox spit
'The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for
this address in a way that will never complete.'
How to ignore the higher level rule?
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL:
lank">http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail:
g">users-unsubscribe@httpd.apache.org
=A0 " =A0 from the digest:
@httpd.apache.org">users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail:
org">users-help@httpd.apache.org
--0016367b6d5e5cbb6f048143a924--
Re: Avoid endless loop of mod_rewrite
am 08.03.2010 10:12:16 von Philip Wigg
On 8 March 2010 05:17, Michael Menegakis wrote:
> Hi all
>
> A rule is in place that that rewrites domains to www.domains
>
> In one particular home dir, I need the opposite,
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
> RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
>
> But it goes into an endless loop that eventually makes firefox spit
>
> 'The page isn't redirecting properly
> Firefox has detected that the server is redirecting the request for
> this address in a way that will never complete.'
>
> How to ignore the higher level rule?
Can you not add an extra RewriteCond to each rule to check if you are
or aren't in the 'one particular home dir' or not? For example:-
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteCond %{REQUEST_URI} ^/homedir/.* <-- This
rule only applies if we're in /homedir/
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/homedir/.* <-- This
rule only applies if we're not in /homedir/, note the exclamation
mark.
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
-- Phil
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Avoid endless loop of mod_rewrite
am 08.03.2010 13:02:11 von Michael Menegakis
On Mon, Mar 8, 2010 at 7:51 AM, Igor Cicimov wrote:
> Try using the following to stop the endless loops:
>
> RewriteCond %{ENV:REDIRECT_STATUS} 200
> RewriteRule .* - [L]
It doesn't stop looping if it's put before the rule, after the rule or
even if it's both after and before the rule.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Avoid endless loop of mod_rewrite
am 08.03.2010 14:49:24 von Nilesh Govindrajan
--00c09f9c97e66e5ddf04814a5652
Content-Type: text/plain; charset=ISO-8859-1
On Mon, Mar 8, 2010 at 10:47 AM, Michael Menegakis wrote:
> Hi all
>
> A rule is in place that that rewrites domains to www.domains
>
> In one particular home dir, I need the opposite,
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
> RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
>
> But it goes into an endless loop that eventually makes firefox spit
>
> 'The page isn't redirecting properly
> Firefox has detected that the server is redirecting the request for
> this address in a way that will never complete.'
>
> How to ignore the higher level rule?
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
RewriteRules have never been a success for me in redirecting domain to
www.domain
I use this config inside a virtualhost for domain.
I.e. I have a virtualhost whose ServerName is set to domain.com
and only one line inside that -
RedirectPermanent / http://www.domain.com/
If you have SSL on your domain, this going to create some problems.
--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
--00c09f9c97e66e5ddf04814a5652
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Mon, Mar 8, 2010 at 10:47 AM, Michael Menegak=
is
<arxeio@gmail.c=
om> wrote:
in: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-l=
eft: 1ex;">
Hi all
A rule is in place that that rewrites domains to www.domains
In one particular home dir, I need the opposite,
RewriteEngine On
RewriteCond %{HTTP_HOST} ^
k">www.domain.com$ [NC]
RewriteRule ^(.*)$
http:=
//domain.com/$1 [R=3D301,L]
But it goes into an endless loop that eventually makes firefox spit
'The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for
this address in a way that will never complete.'
How to ignore the higher level rule?
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL:
lank">http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail:
g">users-unsubscribe@httpd.apache.org
=A0 " =A0 from the digest:
@httpd.apache.org">users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail:
org">users-help@httpd.apache.org
RewriteRules have never been a success f=
or me in redirecting domain to www.domain
I use this config inside a=
virtualhost for domain.
I.e. I have a virtualhost whose ServerName =
is set to
and only one line inside that -
RedirectPermanent /
http://www.domain.com/">http://www.domain.com/
If you have SSL o=
n your domain, this going to create some problems.
-- =
Nilesh Govindarajan
Site & Server Administrator
/www.itech7.com">www.itech7.com
--00c09f9c97e66e5ddf04814a5652--
Re: Avoid endless loop of mod_rewrite
am 09.03.2010 08:57:34 von Michael Menegakis
On Mon, Mar 8, 2010 at 11:12 AM, Philip Wigg wrote:
> On 8 March 2010 05:17, Michael Menegakis wrote:
>> Hi all
>>
>> A rule is in place that that rewrites domains to www.domains
>>
>> In one particular home dir, I need the opposite,
>>
>> RewriteEngine On
>> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
>> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>>
>> But it goes into an endless loop that eventually makes firefox spit
>>
>> 'The page isn't redirecting properly
>> Firefox has detected that the server is redirecting the request for
>> this address in a way that will never complete.'
>>
>> How to ignore the higher level rule?
>
> Can you not add an extra RewriteCond to each rule to check if you are
> or aren't in the 'one particular home dir' or not? For example:-
>
> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
> RewriteCond %{REQUEST_URI} ^/homedir/.* Â Â Â Â =C2=
=A0 Â Â Â Â Â <-- This
> rule only applies if we're in /homedir/
> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>
> RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
> RewriteCond %{REQUEST_URI} !^/homedir/.* Â Â Â Â =C2=
=A0 Â Â Â Â Â <-- This
> rule only applies if we're not in /homedir/, note the exclamation
> mark.
> RewriteRule ^(.*)$ http://www.domain.com/$1 [R=3D301,L]
I do not have access to the httpd. However, the corporation I'm
dealing with doesn't seem to mind with rewriting urls per se, it's
just that it happens this particular hickup is a sideeffect of their
rules and they have no policy of changing httpd conf just for one of
their thousand domains just for one particular account (unless they
buy a server).
So, I was wondering if there's a way .htaccess-side only to just not
go into an infinite loop.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Avoid endless loop of mod_rewrite
am 09.03.2010 10:01:31 von Philip Wigg
On 9 March 2010 07:57, Michael Menegakis wrote:
> On Mon, Mar 8, 2010 at 11:12 AM, Philip Wigg wrot=
e:
>> On 8 March 2010 05:17, Michael Menegakis wrote:
>>> Hi all
>>>
>>> A rule is in place that that rewrites domains to www.domains
>>>
>>> In one particular home dir, I need the opposite,
>>>
>>> RewriteEngine On
>>> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
>>> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>>>
>>> But it goes into an endless loop that eventually makes firefox spit
>>>
>>> 'The page isn't redirecting properly
>>> Firefox has detected that the server is redirecting the request for
>>> this address in a way that will never complete.'
>>>
>>> How to ignore the higher level rule?
>>
>> Can you not add an extra RewriteCond to each rule to check if you are
>> or aren't in the 'one particular home dir' or not? For example:-
>>
>> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
>> RewriteCond %{REQUEST_URI} ^/homedir/.* =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 <-- This
>> rule only applies if we're in /homedir/
>> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>>
>> RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
>> RewriteCond %{REQUEST_URI} !^/homedir/.* =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 <-- This
>> rule only applies if we're not in /homedir/, note the exclamation
>> mark.
>> RewriteRule ^(.*)$ http://www.domain.com/$1 [R=3D301,L]
>
> I do not have access to the httpd. However, the corporation I'm
> dealing with doesn't seem to mind with rewriting urls per se, it's
> just that it happens this particular hickup is a sideeffect of their
> rules and they have no policy of changing httpd conf just for one of
> their thousand domains just for one particular account (unless they
> buy a server).
>
> So, I was wondering if there's a way .htaccess-side only to just not
> go into an infinite loop.
What was wrong with my suggestion of adding an extra RewriteCond?
Remember if you're configuring rewrites in an .htaccess, you'll
probably need to use RewriteBase:-
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewrit ebase
-- Phil.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Avoid endless loop of mod_rewrite
am 09.03.2010 11:41:18 von Michael Menegakis
On Tue, Mar 9, 2010 at 11:01 AM, Philip Wigg wrote:
> On 9 March 2010 07:57, Michael Menegakis wrote:
>> On Mon, Mar 8, 2010 at 11:12 AM, Philip Wigg wro=
te:
>>> On 8 March 2010 05:17, Michael Menegakis wrote:
>>>> Hi all
>>>>
>>>> A rule is in place that that rewrites domains to www.domains
>>>>
>>>> In one particular home dir, I need the opposite,
>>>>
>>>> RewriteEngine On
>>>> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
>>>> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>>>>
>>>> But it goes into an endless loop that eventually makes firefox spit
>>>>
>>>> 'The page isn't redirecting properly
>>>> Firefox has detected that the server is redirecting the request for
>>>> this address in a way that will never complete.'
>>>>
>>>> How to ignore the higher level rule?
>>>
>>> Can you not add an extra RewriteCond to each rule to check if you are
>>> or aren't in the 'one particular home dir' or not? For example:-
>>>
>>> RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
>>> RewriteCond %{REQUEST_URI} ^/homedir/.* Â Â Â Â =C2=
=A0 Â Â Â Â Â <-- This
>>> rule only applies if we're in /homedir/
>>> RewriteRule ^(.*)$ http://domain.com/$1 [R=3D301,L]
>>>
>>> RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
>>> RewriteCond %{REQUEST_URI} !^/homedir/.* Â Â Â Â =
      <-- This
>>> rule only applies if we're not in /homedir/, note the exclamation
>>> mark.
>>> RewriteRule ^(.*)$ http://www.domain.com/$1 [R=3D301,L]
>>
>> I do not have access to the httpd. However, the corporation I'm
>> dealing with doesn't seem to mind with rewriting urls per se, it's
>> just that it happens this particular hickup is a sideeffect of their
>> rules and they have no policy of changing httpd conf just for one of
>> their thousand domains just for one particular account (unless they
>> buy a server).
>>
>> So, I was wondering if there's a way .htaccess-side only to just not
>> go into an infinite loop.
>
> What was wrong with my suggestion of adding an extra RewriteCond?
It goes into an infinite loop again. I believe the root is forcing a
rule by 'inherit'.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Avoid endless loop of mod_rewrite
am 09.03.2010 12:02:44 von Philip Wigg
> It goes into an infinite loop again. I believe the root is forcing a
> rule by 'inherit'.
If I understand you correctly, you don't have access to the main httpd
configuration file. If there's a rewrite in that file which is
redirecting your site from domain.com to www.domain.com then I can't
think of anything you could do to stop it I'm afraid except asking
them not to apply that rule in your case. As you've seen, configuring
a rule to do the same in reverse will merely result in rewrite loops.
-- Phil.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org